package com.cea.papyrus.core.commands;

import org.eclipse.gef.commands.Command;
import org.eclipse.uml2.uml.Element;

import com.cea.papyrus.core.editor.ModelManager;

/**
 * Command that deletes an uml element, based on an EMF command
 */
public class RemoveCommand extends Command{

	/** Wrapped EMF command */
	protected org.eclipse.emf.common.command.Command emfRemoveCommand;
	
	/**
	 * Constructs a Command with the specified label.
	 * @param label the Command's label
	 * @param editing domain linked to the element that will own elements pasted from the clipboard
	 */
	public RemoveCommand (Element umlElement, ModelManager modelManager) {
		setLabel("Remove "+modelManager.getLabelProvider().getText(umlElement));
		emfRemoveCommand= org.eclipse.emf.edit.command.DeleteCommand.create(modelManager.getDiResourceSet().getEditingDomain(), umlElement);
	}

	/* (non-Javadoc)
	 * @see org.eclipse.gef.commands.Command#canExecute()
	 */
	@Override
	public boolean canExecute() {
		return emfRemoveCommand.canExecute();
	}

	/* (non-Javadoc)
	 * @see org.eclipse.gef.commands.Command#canUndo()
	 */
	@Override
	public boolean canUndo() {
		return emfRemoveCommand.canUndo();
	}

	/* (non-Javadoc)
	 * @see org.eclipse.gef.commands.Command#dispose()
	 */
	@Override
	public void dispose() {
		emfRemoveCommand.dispose();
	}

	/* (non-Javadoc)
	 * @see org.eclipse.gef.commands.Command#execute()
	 */
	@Override
	public void execute() {
		emfRemoveCommand.execute();
	}

	/* (non-Javadoc)
	 * @see org.eclipse.gef.commands.Command#redo()
	 */
	@Override
	public void redo() {
		emfRemoveCommand.redo();
	}

	/* (non-Javadoc)
	 * @see org.eclipse.gef.commands.Command#undo()
	 */
	@Override
	public void undo() {
		emfRemoveCommand.undo();
	}



}
